﻿using JzSport.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JzSport.Api
{
    /// <summary>
    /// 退出活动
    /// </summary>
    class LeaveActivityAction : AuthPostAction<Params.LeaveActivityParams,
        Results.LeaveActivityResult>
    {
        protected override ActionResult<Results.LeaveActivityResult> OnExecute(ActionContext context, SysParameters sysParameters,
            Params.LeaveActivityParams opParams)
        {
            ServiceResult<ActivityMember> serviceResult = new ActivityService().Leave(context.AccountId,
                opParams.ActivityId);

            Results.LeaveActivityResult actionResult = new Results.LeaveActivityResult();
            if (serviceResult.ErrorCode == ErrorCode.NoError)
            {
                return new ActionResult<Results.LeaveActivityResult>("1.0.1", true, serviceResult.ErrorCode,
                    ErrorCode.ToString(serviceResult.ErrorCode), actionResult);
            }
            return new ActionResult<Results.LeaveActivityResult>("1.0.1", false, serviceResult.ErrorCode,
                    ErrorCode.ToString(serviceResult.ErrorCode), actionResult);
        }
    }
}
